package com.yuoj.yuojbackendjudgeservice.codesandbox.proxy;

import cn.hutool.json.JSONUtil;
import com.yuoj.backendcommon.codesandbox.ExecuteCodeRequest;
import com.yuoj.backendcommon.codesandbox.ExecuteCodeResponse;
import com.yuoj.yuojbackendjudgeservice.codesandbox.CodeSandBox;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 刘渠好
 * @since 2025-01-15 22:54
 * 代码沙箱代理模式优化
 */
@Slf4j
public class CodeSandBoxProxy implements CodeSandBox {

    private final CodeSandBox codeSandBox;

    public CodeSandBoxProxy(CodeSandBox codeSandBox) {
        this.codeSandBox = codeSandBox;
    }
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest request) {
        log.info ("代码沙箱请求数据：{}",JSONUtil.toJsonStr (request));
        ExecuteCodeResponse codeResponse = codeSandBox.executeCode (request);
        log.info ("代码沙箱响应数据：{}",JSONUtil.toJsonStr (codeResponse));
        return codeResponse;
    }
}
